package thread.Executor;

import java.util.List;
import java.util.concurrent.*;

/**
 * @author huangguo
 * @time 19-8-3 下午2:07
 */
public class Main {
    public static void main(String[] args) throws Exception {

        ExecutorService consumerPool = new ThreadPoolExecutor(1, 5,
                60, TimeUnit.SECONDS,
                new SynchronousQueue<Runnable>());
        consumerPool.execute(() -> {
            System.out.println("1");
        });
        consumerPool.execute(() -> {
            System.out.println("2");
        });
        consumerPool.execute(() -> {
            System.out.println("3");
        });
        consumerPool.execute(() -> {
            System.out.println("4");
        });
        consumerPool.execute(() -> {
            System.out.println("5");
        });
        consumerPool.execute(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("6");
        });
        consumerPool.execute(() -> {
            System.out.println("7");
        });
        consumerPool.shutdown();
        System.out.println("8");
    }

    public <T extends Main> void s(List<T> t){
        return;
    }
}

